package com.learn.my;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class Test0007 {

    public static void main(String[] args){
        ThreadPoolExecutor threadPoolExecutor=new ThreadPoolExecutor(1,2,0L, TimeUnit.MINUTES,new LinkedBlockingDeque<Runnable>(3));


        threadPoolExecutor.execute(new TaskRunable("任务1"));
        threadPoolExecutor.execute(new TaskRunable("任务2"));
        threadPoolExecutor.execute(new TaskRunable("任务3"));
        threadPoolExecutor.execute(new TaskRunable("任务4"));
        threadPoolExecutor.execute(new TaskRunable("任务5"));
        threadPoolExecutor.execute(new TaskRunable("任务6"));

    }
}

class TaskRunable implements Runnable{
    public TaskRunable(String name) {
        this.name = name;
    }

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+","+name);
    }

    private String name;
}